package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.mapper.DepartmentMapper;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.DepartmentService;
import cn.wolfcode.crm.domain.Department;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public void insert(Department department) {
        departmentMapper.insert(department);
    }

    @Override
    public void deleteByPrimaryKey(Long id) {
        departmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Department selectByPrimaryKey(Long id) {

        return departmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Department> selectAll() {
        return departmentMapper.selectAll();
    }


    @Override
    public void updateByPrimaryKey(Department department) {
        departmentMapper.updateByPrimaryKey(department);
    }

    @Override
    public PageInfo<Department> query(QueryObject qo) {
       //查询部门数据
        PageHelper.startPage(qo.getCurrentPage(),qo.getPagSize());

        return new PageInfo<>(departmentMapper.queryForList(qo));
    }

}
